import { MapData } from "@/class/map/MapData";
import { getRandomColor } from "@/utils/utils";
import { MapCoordSys, MapType } from "./myMapOpt";
import { Marker, MarkerData } from "./Marker";
import { Polygon, PolygonData } from "./Polygon";

export class Feature {
    id?: string
    featureId?: string
    featuresId?: string
    attributes?: object
    parentId?: string
    name?: string
    geometry?: any
    childrenFeatures?: Features

    constructor({ id, featureId, featuresId, attributes, parentId, name, geometry, childrenFeatures }: {
        id?: string
        featureId?: string
        featuresId?: string
        attributes?: object
        parentId?: string
        name?: string
        geometry?: any
        childrenFeatures?: Features
    }) {
        this.id = id
        this.featureId = featureId
        this.featuresId = featuresId
        this.attributes = attributes
        this.parentId = parentId
        this.name = name
        this.geometry = JSON.parse(geometry)
        this.childrenFeatures = childrenFeatures
    }
    getMyMap() {    

        var myMap = new PolygonData({
            featureData: new MapData({
                type:MapType.Polygon,
                name:this.name,
                top:false,
                coordsys:MapCoordSys.GPS
            }),
            featureMap: new Polygon({
                fillColor:getRandomColor(),
                strokeColor:getRandomColor(),
                fillOpacity:0.5,
                path:this.geometry
            })
        });
        return myMap;
    }
}
export class Features {
    id?: string
    level?: number
    geometryType?: string
    fields?: object
    features?: []
    featuresName?: string
    constructor({id,level, geometryType,fields,features,featuresName}:{
        id?:string
            level?:number
            geometryType?:string
            fields?:object
            features?:[]
            featuresName?:string
    }){
        this.id=id
        this.level=level
        this.geometryType=geometryType
        this.fields=fields
        this.features=features
        this.featuresName=featuresName
    }
}